package action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;

import entity.User;

public class UserAction extends ActionSupport implements SessionAware {

	private User user;
	private String msg;
	private Map<String, Object> session;

	public String login() {
		if (user.getUsername().equals("admin")
				&& user.getPassword().equals("111")) {
			session.put("user", user);
			msg = "登录成功";
		} else {
			msg = "登录失败";
		}
		return SUCCESS;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	/**
	 * 获取 user
	 * 
	 * @return user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * 设置 user
	 * 
	 * @param user
	 *            user
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * 获取 msg
	 * 
	 * @return msg
	 */
	public String getMsg() {
		return msg;
	}

	/**
	 * 设置 msg
	 * 
	 * @param msg
	 *            msg
	 */
	public void setMsg(String msg) {
		this.msg = msg;
	}

	/**
	 * 获取 session
	 * 
	 * @return session
	 */
	public Map<String, Object> getSession() {
		return session;
	}

}
